package com.tdzx.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.tdzx.util.StringUtils;

public class Comment {
	private String goods_Id;
	private String comment_Id;
	private String member_Id;
	private String comment_Content;
	private String goods_name;
	private long comment_Date;
	private double comment_price;
	private double comment_code;
	private String memberName;
	private String memberimage;
	
	public String getMemberimage() {
		return memberimage;
	}
	public void setMemberimage(String memberimage) {
		this.memberimage = memberimage;
	}
	public String getMemberName() {
		return memberName;
	}
	public void setMemberName(String memberName) {
		this.memberName = memberName;
	}
	public double getComment_price() {
		return comment_price;
	}
	public void setComment_price(double comment_price) {
		this.comment_price = comment_price;
	}
	public double getComment_code() {
		return comment_code;
	}
	public void setComment_code(double comment_code) {
		this.comment_code = comment_code;
	}
	public String getGoods_Id() {
		return goods_Id;
	}
	public void setGoods_Id(String goods_Id) {
		this.goods_Id = goods_Id;
	}
	public String getComment_Id() {
		return comment_Id;
	}
	public void setComment_Id(String comment_Id) {
		this.comment_Id = comment_Id;
	}
	public String getMember_Id() {
		return member_Id;
	}
	public void setMember_Id(String member_Id) {
		this.member_Id = member_Id;
	}
	public String getComment_Content() {
		return comment_Content;
	}
	public void setComment_Content(String comment_Content) {
		this.comment_Content = comment_Content;
	}
	public String getGoods_name() {
		return goods_name;
	}
	public void setGoods_name(String goods_name) {
		this.goods_name = goods_name;
	}
	public long getComment_Date() {
		return comment_Date;
	}
	public void setComment_Date(long comment_Date) {
		this.comment_Date = comment_Date;
	}
	
	
	public static List<Comment> getCommentList(String json) {
		List<Comment> list = new ArrayList<Comment>();
		try {
			if(StringUtils.isSuccessTD(json)) {
				JSONObject jo_all = new JSONObject(json);
				JSONArray ja = jo_all.optJSONArray("resutObject");
				if(ja != null) {
					for(int i = 0; i < ja.length(); i++) {
						JSONObject jo = ja.optJSONObject(i);
						Comment comment = new Comment();
						comment.setComment_Content(jo.optString("comment_Content"));
						comment.setComment_Date(jo.getLong("comment_Date"));
						comment.setComment_Id(jo.optString("comment_Id"));
						comment.setGoods_Id(jo.optString("goods_Id"));
						comment.setGoods_name(jo.optString("goods_name"));
						comment.setMember_Id(jo.optString("member_Id"));
						comment.setComment_code(jo.optDouble("comment_code"));
						comment.setComment_price(jo.optDouble("comment_price"));
						comment.setMemberName(jo.optString("memberName"));
						comment.setMemberimage(jo.optString("memberimage"));
						list.add(comment);
					}
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return list;
	}
	
	public static List<Comment> getCommentListMy(String json) {
		List<Comment> list = new ArrayList<Comment>();
		try {
				JSONArray ja = new JSONArray(json);
				if(ja != null) {
					for(int i = 0; i < ja.length(); i++) {
						JSONObject jo = ja.optJSONObject(i);
						Comment comment = new Comment();
						comment.setComment_Content(jo.optString("comment_Content"));
						comment.setComment_Date(jo.getLong("comment_Date"));
						comment.setComment_Id(jo.optString("comment_Id"));
						comment.setGoods_Id(jo.optString("goods_Id"));
						comment.setGoods_name(jo.optString("goods_name"));
						comment.setMember_Id(jo.optString("member_Id"));
						comment.setComment_code(jo.optDouble("comment_code"));
						comment.setComment_price(jo.optDouble("comment_price"));
						comment.setMemberName(jo.optString("memberName"));
						list.add(comment);
					}
				}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return list;
	}
}
